package zw_801_900.zw_867_转置矩阵;

class Solution {
    public static void main(String[] args) {
        int[][] matrix = {{1,2,3},{4,5,6},{7,8,9}};
        int[][] transpose = transpose(matrix);
        for (int[] ints : transpose) {
            for (int i : ints) {
                System.out.print(i + " ");
            }
            System.out.println();
        }
    }

    public static int[][] transpose(int[][] matrix) {
        int row = matrix.length, column = matrix[0].length;
        int[][] transposed = new int[column][row];
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < column; j++) {
                transposed[j][i] = matrix[i][j];
            }
        }
//        for(int i = 0 ; i < row * column ; i ++){
//            transposed[i/row][i%row]  = matrix[i%row][i/row];
//        }
        return transposed;
    }
}
